package com.mao.wx.demo.model.message;

import java.util.Date;
import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

public class WxBasicMessage {

	protected String ToUserName;

	protected String FromUserName;

	protected Long CreateTime;

	protected String MsgType;
	
	protected Long MsgId;
	
	
	public WxBasicMessage() {
	}

	public WxBasicMessage(Map<String,String> map) throws Exception{
		this(map,false);
	}
	
	public WxBasicMessage(Map<String,String> map,boolean isResponse) throws Exception{
		if(isResponse){//设置回复类型消息
			this.ToUserName=map.get("FromUserName");
			this.FromUserName=map.get("ToUserName");
			this.CreateTime=new Date().getTime();
			this.MsgType=map.get("MsgType");
		}else{//设置接受类型消息
			this.ToUserName=map.get("ToUserName");
			this.FromUserName=map.get("FromUserName");
			this.CreateTime=Long.parseLong(map.get("CreateTime"));
			this.MsgType=map.get("MsgType");
			this.MsgId=Long.parseLong(map.get("MsgId"));
		}
	}
	
	public long getMsgId() {
		return MsgId;
	}

	public void setMsgId(Long msgId) {
		this.MsgId = msgId;
	}

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUserName) {
		this.ToUserName = toUserName;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		this.FromUserName = fromUserName;
	}

	public long getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Long createTime) {
		this.CreateTime = createTime;
	}

	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		this.MsgType = msgType;
	}
	
	
	
}
